AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:SpawnFunction(ply,tr)
	if(!tr.Hit)then return end
	local SpawnPos=tr.HitPos+tr.HitNormal*16
	local ent=ents.Create("ration")
	ent:SetPos(SpawnPos)
	ent.ShareGravgun=true
	ent.nodupe=true
	ent:Spawn()
	ent:Activate()
	return ent
end

function ENT:Initialize()
	self:SetModel("models/weapons/w_package.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	local phys=self:GetPhysicsObject()
	if phys and phys:IsValid() then phys:Wake() end
	self.damage=10
	self.dt.amount=20--Containing money
end

function ENT:OnTakeDamage(dmg)
	self.damage=self.damage-dmg:GetDamage()
end

function ENT:Use(activator,caller)
	if caller:Team()<8 then
		caller:AddMoney(self.dt.amount)
		self:Remove()
	else
		caller:ChatPrint("Combines have no use for money.")
		return false
	end
end

function ENT:OnRemove()
	local ply=self.dt.owning_ent
end